<div class="row">
    <div class="col-md-12 widget-module">
        <div class="box-widget">
            <div class="widget-head clearfix">
                <h4 class="pull-left"><?php echo $this->translate('create banner'); ?></h4>
            </div>
            
            <div class="widget-container">
                <div class="widget-block">
                    <div class="widget-content">
                        <form id="usergroup" method="post" class="form-horizontal form-box">
                            <div class="form-group <?php echo $this->classError['banner']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('banner'); ?></label>
                                <div class="col-lg-4">
                                    <input class="form-control" type="text" value="<?php echo $this->data['banner']; ?>" name="banner" class="form-control" placeholder="<?php echo $this->translate('banner'); ?>" />
                                    <?php echo $this->messageError['banner']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['image']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('image'); ?></label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input id="image" class="form-control" type="text" value="<?php echo $this->data['image']; ?>" name="image" class="form-control" placeholder="<?php echo $this->translate('image'); ?>" />
                                        <span class="input-group-btn">
                                            <a id="iframe-btn" href="<?php echo $this->baseUrl(); ?>/filemanager/dialog.php?type=1&subfolder=&editor=mce_0&field_id=image">
                                                <button class="btn btn-default" type="button">
                                                    <span class="icon-folder-open" aria-hidden="true"></span>
                                                </button>
                                            </a>
                                        </span>
                                    </div>
                                    <?php echo $this->messageError['image']; ?>
                                </div>
                            </div>
                            
                            <?php
                                if(!isset($this->data['image'])){
                                    $src = $this->templateURL . "/images/grid-default-thumb.png";
                                }else{
                                    $src = $this->data['image'];
                                }
                            ?>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('current image'); ?></label>
                                <div class="col-lg-4">
                                    <div class="current-image">
                                        <img class="current-image" src="<?php echo $src; ?>" />
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['link']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('link'); ?></label>
                                <div class="col-lg-4">
                                    <input class="form-control" type="text" value="<?php echo $this->data['link']; ?>" name="link" class="form-control" placeholder="<?php echo $this->translate('link'); ?>" />
                                    <?php echo $this->messageError['link']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['position']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('position'); ?></label>
                                <div class="col-lg-4">
                                    <select class="form-control" name="position">
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'slider') echo 'selected="selected"'; ?> value="slider">Slider</option>
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'top') echo 'selected="selected"'; ?> value="top">Top</option>
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'bottom') echo 'selected="selected"'; ?> value="bottom">Bottom</option>
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'top_content') echo 'selected="selected"'; ?> value="top_content">Top content</option>
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'sidebar') echo 'selected="selected"'; ?> value="sidebar">Sidebar</option>
                                        <option <?php if(isset($this->data['position']) && $this->data['position'] == 'logo') echo 'selected="selected"'; ?> value="logo">Logo</option>
                                    </select>
                                    <?php echo $this->messageError['position']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group  <?php echo $this->classError['time']; ?>">
                                <label class="col-lg-2 control-label" for="reservation"><?php echo $this->translate('time'); ?></label>
                                <div class="col-lg-4">
                                    <input id="daterange" value="<?php echo $this->data['time']; ?>" readonly="" class="form-control" type="text" name="time" placeholder="<?php echo $this->translate('time'); ?>" />
                                    <?php echo $this->messageError['time']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('status'); ?></label>
                                <div class="col-lg-4">
                                    <div class="checkbox">
                                        <label>
                                            <input <?php if($this->data['status']) echo 'checked="checked"'; ?> type="checkbox" name="status" value="1" />
                                            <?php echo $this->translate('active'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label">&nbsp;</label>
                                <div class="col-lg-4">
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-primary">
                                            <i class="icon-save"></i>
                                            <?php echo $this->translate('save'); ?>
                                        </button>
                                        <button id="cancel" type="button" class="btn">
                                            <i class="icon-cancel-circle-2"></i>
                                            <?php echo $this->translate('cancel'); ?>
                                        </button>
                                    </div>
                                </div>
                            </div> 
                            <?php if(isset($this->data['id']) && $this->data['id'] > 0): ?>
                            <input type="hidden" name="id" value="<?php echo $this->data['id']; ?>" />
                            <input type="hidden" name="save" value="1" />
                            <?php endif; ?>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$("#cancel").click(function(){
    window.location = "<?php echo $this->url(array('module' => 'admin', 'controller' => 'banner', 'action' => 'index'), null, true); ?>";
});

$(document).ready(function(){
    $('#iframe-btn').fancybox({	
    	'width'		: 900,
    	'height'	: 600,
    	'type'		: 'iframe',
        'autoScale'    	: false,
        'margin'    : 70,
    });
});

$(function() {
    var today = new Date();
    var nextYear = '12/31/' + (today.getFullYear() + 1);
    
    $('#daterange').daterangepicker(
        {
            minDate: today,
            maxDate: nextYear,
            showDropdowns: true,
        }
    );
});
</script>